package edu.ynu.se.xiecheng.achitectureclass.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Inheritance
@Where(clause = "is_deleted = 0")
@Table(name = "item")
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
public class Item extends LogicEntity {

    @Schema(description = "名称")
    @Column(length = 128)
    private String name;

    @Schema(description = "描述")
    @Column(length = 512)
    private String description;

    @Column
    @Schema(description = "价格")
    private Double price;

    @OneToMany(mappedBy = "item",fetch = FetchType.LAZY,cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value = {"item"})
    private Set<ShopItem> shopItems;
}
